package com.iskny.framework.admin.interceptor;

import com.iskny.framework.kit.UserMenusKit;
import com.iskny.framework.model.UserBean;
import com.iskny.framework.session.UserSession;
import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.core.Controller;

/**
 * 数据补充
 * @author 伟强
 *
 */
public class AdminDataInterceptor implements Interceptor {

	public AdminDataInterceptor(){
	}
	@Override
	public void intercept(ActionInvocation ai) {
		Controller c = ai.getController();
		UserSession u = new UserSession(c.getSession());
		UserBean user = u.getAttr();
		if(user!=null&&user.getType()==UserBean.ADMIN){
			c.setAttr("_menus", UserMenusKit.loadMenus(user.getId()));
		}
		ai.invoke();
	}

}
